package com.team;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author 樊浩
 * @version 1.0
 * @description: TODO
 * @date 2021/3/5 14:47
 */
public class Test2 {
 public static void main(String[] args) {
  //使用jedis基于连接池操作Redis的步骤
  //1.创建连接池对象
  //1.1创建连接配置对象
  JedisPoolConfig config=new JedisPoolConfig();
  config.setMaxTotal(60);//设置最大连接数
  //1.2.创建数据库连接池
  JedisPool pool=new JedisPool(config,"localhost",6379);
  //2.基于连接池获取Jedis对象
  Jedis jedis=pool.getResource();
  //3.操作Redis
  jedis.set("age","18");
  String str=jedis.get("age");

  jedis.set("xh","1000111");
  String s=jedis.get("xh");
  System.out.println(str);
  System.out.println(s);
  //4.关闭对象
  jedis.close();
 }
}
